home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11385 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: nntp1.best.com!zenin
  2. From: Zenin <zenin@best.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Limiting stdin input to "n" chars
  5. Date: 23 Mar 1996 19:06:17 GMT
  6. Organization: Rocky Horror, Barely Legal (Berkeley, CA)
  7. Message-ID: <4j1i39$jso@nntp1.best.com>
  8. References: <4hqfmc$un7@thorn.cc.usm.edu> <4icer1$df5@altrade.nijmegen.inter.nl.net> <4if7k6$9ro@news.xs4all.nl>
  9. NNTP-Posting-Host: shellx.best.com
  10.  
  11. Falstaff <falstaff@xs4all.nl> wrote:
  12.     >snip<
  13. : No won't work.  fgets() uses the standard I/O library which will
  14. : wait for a linefeed anyway.
  15.  
  16.     I'm having similar problems.  So just how does one just grap the
  17.     first char (or n chars) and move on without needing the line feed?
  18.  
  19.     What I'm trying to do is simply ask a y/n question of the user so
  20.     that they only have to enter "y" or "n" without having to also give
  21.     the anoying line feed.
  22.  
  23.     If this is not part of the std lib somewere, someone out there
  24.     /must/ (assuming, danger!) have writen a function to do this...?
  25.  
  26.     I thought simply
  27.         int c;
  28.         c = getchar();
  29.         if (c ==...etc...
  30.     would do it, but of course I'm wrong... :(
  31.  
  32.     TIA!
  33. ______
  34.      /    Spelling mistakes?  Their couldn't be. -My modem is error correcting.
  35.     /    
  36.    /    Zenin@Best.com            ---->>ROCKY HORROR ARCHIVE<<----
  37.   /     ___     __  o   __           
  38.  /    /___\ |/  \ | |/  \               http://www.best.com/~zenin/
  39. /_______\___  |      | | |   |_______________________________________________
  40.